package com.sxm.yiwei.activitis;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

import com.sxm.yiwei.MainActivity;
import com.sxm.yiwei.R;
import com.sxm.yiwei.adapters.IntroAdapter;

import java.util.ArrayList;
import java.util.List;

public class HotSendSelectTypeActivity extends BaseActivity implements View.OnClickListener{

    private ImageView sendtyprback;
    private String from;
    private GridView sendlist;
    private ArrayAdapter<String> adapter;
    private Intent in;
    private Intent intent;
    IntroAdapter adapter1 = null;
    private ImageView backmain;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hot_send_select_type);
        intent = getIntent();
        from = intent.getStringExtra("from");
        initSendtypeView();


    }

    private void initSendtypeView() {
        sendtyprback = (ImageView) findViewById(R.id.hotsend_typeback);
        backmain = (ImageView) findViewById(R.id.hotselect_backmain);
        backmain.setOnClickListener(this);
        sendtyprback.setOnClickListener(this);
        sendlist = (GridView) findViewById(R.id.hotsend_typelist);
        List<String>data = new ArrayList();
        /**
         *   tmp = @[@"鲜花",@"蛋糕",@"水果",@"外卖",@"衣服",
         @"证件",@"手机",@"酒水",@"宠物",@"珠宝",
         @"零食",@"礼品",@"药品",@"生活用品",@"其他"];
         */
        data.add("鲜花");
        data.add("蛋糕");
        data.add("水果");
        data.add("外卖");
        data.add("衣服");
        data.add("证件");
        data.add("手机");
        data.add("酒水");
        data.add("宠物");
        data.add("珠宝");
        data.add("零食");
        data.add("礼品");
        data.add("药品");
        data.add("生活用品");
        data.add("其他");


        /**
         *    tmp = @[@"帮买",@"代买",@"排队",@"挂号",@"送礼",
         @"代驾",@"按摩",@"打扫卫生",@"洗衣服",@"住院陪护",
         @"老人陪护",@"帮接送",@"帮缴费",@"帮搬家",@"做饭",
         @"陪跑步",@"照顾宠物",@"陪玩",@"替上课",@"占座",
         @"帮车点火",@"维修",@"修电脑",@"修水管",@"修马桶",
         @"修电灯",@"做苦力",@"找临时女（男）友",@"其他"];

         */
        List<String> data1 = new ArrayList<>();
        data1.add("帮买");
        data1.add("代买");
        data1.add("排队");
        data1.add("挂号");
        data1.add("送礼");
        data1.add("代驾");
        data1.add("按摩");
        data1.add("打扫卫生");
        data1.add("洗衣服");
        data1.add("住院陪护");
        data1.add("老人陪护");
        data1.add("帮接送");
        data1.add("帮缴费");
        data1.add("帮搬家");
        data1.add("做饭");
        data1.add("陪跑步");
        data1.add("照顾宠物");
        data1.add("陪玩");
        data1.add("替上课");
        data1.add("占座");
        data1.add("帮车点火");
        data1.add("维修");
        data1.add("修电脑");
        data1.add("修水管");
        data1.add("修马桶");
        data1.add("修电灯");
        data1.add("做苦力");
        data1.add("找临时女（男）友");
        data1.add("其他");

        if (from.equals("1")){
           // adapter = new ArrayAdapter(HotSendSelectTypeActivity.this,android.R.layout.simple_list_item_1,data);
            adapter1 = new IntroAdapter(HotSendSelectTypeActivity.this,data);
        }else {
       // adapter = new ArrayAdapter(HotSendSelectTypeActivity.this,android.R.layout.simple_list_item_1,data1);
            adapter1 = new IntroAdapter(HotSendSelectTypeActivity.this,data1);
        }




       // final ArrayAdapter<String> adapter = new ArrayAdapter(HotSendSelectTypeActivity.this,android.R.layout.simple_list_item_1,data);
        sendlist.setAdapter(adapter1);
        sendlist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String item = (String) adapter1.getItem(position);
                Bundle bb = new Bundle();
                bb.putString("item",item);
                intent.putExtras(bb);
               HotSendSelectTypeActivity.this.setResult(RESULT_OK,intent);
                finish();
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.hotsend_typeback:
                finish();
                break;
            case R.id.hotselect_backmain:

                startActivity(new Intent(HotSendSelectTypeActivity.this, MainActivity.class));
                AppManager.getAppManager().finishAllActivity();
                break;
        }
    }
}
